﻿//********************************************************************************//
//创建日期：<创建日期，2016-05-12>
//创建作者：<郭登杰，guodengjie@shanghai3h.com>
//功能说明：来函流程工具类
//********************************************************************************//

using System;
using System.Collections.Generic;
using System.Data;
using System.Web.UI;
using BLL;
using BLL.Access;
using Entity;
using Web.Controls.LAIHAN;

namespace Web.Class
{
    /// <summary>
    ///     来函流程工具类
    /// </summary>
    public class LaiHanLCTools
    {
        /// <summary>
        ///     更新当前完成步骤的结束时间,并插入下一步骤,若为最后一步,则更新对应的计划表
        /// </summary>
        /// <param name="laihanxx"></param>
        /// <param name="spjg">同意,不同意</param>
        /// <param name="cross">是否直接通过及完成流程</param>
        public static void AddNextFlow(YS_LH_LAIHANXX laihanxx, eLaiHanSPJG spjg, bool cross)
        {
            var userid = LoginInfo.CurrentUser.UserID.ToString();
            var username = LoginInfo.CurrentUser.UserName;
            var time = "to_date('" + DateTime.Now + "','yyyy-MM-dd HH24:mi:ss')";
            var lhxxT = new YS_LH_LAIHANXXProcess();
            //更新当前步骤结束时间,操作人
            var lcbllt = new YS_LH_LAIHANLCJLProcess();
            lcbllt.UpdateYS_LH_LAIHANLCJLsDynamic("I_CAOZUOR='" + userid + "',S_CAOZUORQM='" + LoginInfo.CurrentUser.ElectronSign + "',D_ENDDATE=" + time,
                "I_JLZT=0 AND S_LAIHANBH=" + laihanxx.S_LAIHANBH + " AND I_LIUCHENGBH=" + laihanxx.I_LIUCHENGBH);
            //如果是月度,将操作人与时间存入ys_lh_yuetiaoz
            if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.月度)
            {
                string sets = laihanxx.I_LIUCHENGBH == (int)eLaiHanLCBH.业务员 ? "I_YWY=" + userid.ToString() + ",D_YWY=" + time :
                                laihanxx.I_LIUCHENGBH == (int)eLaiHanLCBH.主任 ? "I_ZR=" + userid.ToString() + ",D_ZR=" + time :
                                laihanxx.I_LIUCHENGBH == (int)eLaiHanLCBH.节水科 ? "I_JSK=" + userid.ToString() + ",D_JSK=" + time :
                                laihanxx.I_LIUCHENGBH == (int)eLaiHanLCBH.计财科 ? "I_JCK=" + userid.ToString() + ",D_JCK=" + time :
                                laihanxx.I_LIUCHENGBH == (int)eLaiHanLCBH.处长 ? "I_CZ=" + userid.ToString() + ",D_CZ=" + time : "";
                new YS_LH_YUETIAOZProcess().UpdateYS_LH_YUETIAOZsDynamic(sets, "S_LAIHANBH='" + laihanxx.S_LAIHANBH + "'");
            }
            SpHelper spHelper = new SpHelper();
            /*更新待处理操作人*/
            int? state = -1;
            string msg = null;
            int? nextflowno=0;
            string nextflowname = "";
            int liuchengzt = 0;//记录当前来函流程状态.为1时表示已结束.
            //如果审批结果为不同意,则来函主信息更新为不通过
            if (laihanxx.I_LIUCHENGBH >= (int)eLaiHanLCBH.主任 && spjg == eLaiHanSPJG.不同意)
            {
                laihanxx.I_LIUCHENGZT = (int)eLaiHanLCZT.不通过;
                lhxxT.InsertOrUpdate(laihanxx);
                liuchengzt = 1;
                spHelper.P_YSLH_DAICHULCZR(laihanxx.S_LAIHANBH, (int?)laihanxx.I_LAIHANLX, (int?)laihanxx.I_LIUCHENGBH, liuchengzt, laihanxx.S_YONGHUBH,out nextflowno,out nextflowname, out state, out msg);
                return;
            }
            var over = false;            
            //月度如果调整量小于千吨 并且当前流程为计财科,则流程结束
            if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.月度)
            {
                if ((int)laihanxx.I_LIUCHENGBH == (int)eLaiHanLCBH.计财科)
                {
                    int? ysltemp = 0;
                    DataRowCollection drc = new YS_LH_YUETIAOZProcess().SelectYS_LH_YUETIAOZsDynamic("I_JLZT=0 AND S_LAIHANBH='" + laihanxx.S_LAIHANBH + "'", null).Rows;
                    if (drc.Count == 0)
                    {
                        throw new Exception("数据异常,请联系技术人员");
                    }
                    ysltemp = Convert.ToInt32(drc[0]["I_SHENQINGL"]);
                    //new SpHelper().P_YS_YSL_Y(laihanxx.S_LAIHANBH, laihanxx.S_YONGHUBH, (int)laihanxx.I_TZY, (int)laihanxx.I_TZM, out ysltemp);
                    over = (ysltemp <= 1000);
                    liuchengzt = (ysltemp <= 1000) ? 1 : 0;
                }
            }
            spHelper.P_YSLH_DAICHULCZR(laihanxx.S_LAIHANBH, (int?)laihanxx.I_LAIHANLX, (int?)laihanxx.I_LIUCHENGBH, liuchengzt, laihanxx.S_YONGHUBH, out nextflowno, out nextflowname, out state, out msg);
            if (state < 0)
            {
                throw new Exception(msg);
            }
            ////添加下一步流程,如果存在的话
            //int? nextflowno=0;
            //string nextflowname = "";
            //spHelper.P_YSLH_GETNEXTFLOWNO(laihanxx.S_LAIHANBH, (int?)laihanxx.I_LAIHANLX, (int?)laihanxx.I_LIUCHENGBH, laihanxx.S_YONGHUBH, out nextflowno,out nextflowname, out state, out msg);
            if (nextflowno>0 && !over && !cross)
            {
                //更新当前来函状态为下一步
                lhxxT.UpdateYS_LH_LAIHANXXesDynamic("I_LIUCHENGBH=" + nextflowno,
                    "I_JLZT=0 AND S_LAIHANBH=" + laihanxx.S_LAIHANBH);
                var lcjl = new YS_LH_LAIHANLCJL();
                lcjl.S_CAOZUORQM = null;
                lcjl.D_CAOZUORQ = DateTime.Now;
                lcjl.D_STARTDATE = DateTime.Now;
                lcjl.D_ENDDATE = null;
                //lcjl.I_CAOZUOR = Entity.LoginInfo.CurrentUser.UserID;
                lcjl.I_LAIHANLX = laihanxx.I_LAIHANLX;
                lcjl.I_LIUCHENGBH = nextflowno;
                lcjl.S_LIUCHENGMC = nextflowname;
                lcjl.S_LAIHANBH = laihanxx.S_LAIHANBH;
                lcjl.ID = 0;
                //添加下一步流程                
                DataTable lcxx = lcbllt.SelectYS_LH_LAIHANLCJLsDynamic(
                    string.Format(" S_LAIHANBH='{0}' and I_LIUCHENGBH={1} ", laihanxx.S_LAIHANBH, lcjl.I_LIUCHENGBH),
                    "", null);
                if (lcxx != null && lcxx.Rows.Count > 0)
                    lcjl.ID = Convert.ToInt32(lcxx.Rows[0]["ID"]);
                lcbllt.InsertOrUpdate(lcjl);
            }
            else if (nextflowno == 0 || over || cross) //当前为最后一步(或按条件结束或调用时指定直接结束),按来函类别更新
            {
                var helpTemp = new SpHelper();
                var helpSQL = new BLL.SqlHelper();
                //更新当前来函流程状态为结束流程
                //int lczt=laihanxx.I_LAIHANLX==(int)eLaiHanLX.月度?0:1;
                var lczt = 1;
                var updateSets = string.Format("I_LIUCHENGZT={0},I_SHENPIR={1},S_SHENPIR='{2}',D_SHENPIRQ={3}", lczt,
                    userid, username, time);
                lhxxT.UpdateYS_LH_LAIHANXXesDynamic(updateSets, "I_JLZT=0 AND S_LAIHANBH=" + laihanxx.S_LAIHANBH);
                //如果为月度 不做处理 复审修改页面处理
                if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.月度)
                {
                    int? no = -1;
                    //执行月调整审批同步
                    helpTemp.P_YS_LH_UPDATETIAOZHENGJH(laihanxx.S_LAIHANBH, laihanxx.S_YONGHUBH, (int)laihanxx.I_LIUCHENGBH, LoginInfo.CurrentUser.UserID, LoginInfo.CurrentUser.UserID.ToString(), out no);
                    //更新用户信息
                    //UpdateYongHuXX(laihanxx.S_LAIHANBH);//20190325去掉用户信息更新
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.年度)
                {
                    //执行年度调整通过同步
                    helpTemp.P_YSLH_NIANDUTZSPTGTB(laihanxx.S_LAIHANBH);
                    //更新用户信息
                    //UpdateYongHuXX(laihanxx.S_LAIHANBH);//20190325去掉用户信息更新
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.基建调整)
                {
                    int? error = 0;
                    //备份计划信息
                    helpTemp.P_YS_LH_BEIFENJHXX(laihanxx.S_LAIHANBH, laihanxx.S_YONGHUBH, out error);
                    //执行基建调整通过同步
                    helpTemp.P_YS_LH_JIJIANSPTGTB(laihanxx.S_LAIHANBH, laihanxx.S_YONGHUBH,
                        LoginInfo.CurrentUser.UserID.ToString());
                    //更新用户信息
                    //UpdateYongHuXX(laihanxx.S_LAIHANBH);//20190325去掉用户信息更新
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.计划变更)
                {
                    //执行计划变更通过同步
                    helpTemp.P_YSLH_JIHUABGTGTB(laihanxx.S_LAIHANBH, LoginInfo.CurrentUser.UserID.ToString());
                    //更新用户信息
                    //UpdateYongHuXX(laihanxx.S_LAIHANBH);//20190325去掉用户信息更新
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.表计因素注销)
                {
                    //执行计划变更通过同步
                    helpTemp.P_YSLH_BIAOJIYSZXTGTB(laihanxx.S_LAIHANBH, LoginInfo.CurrentUser.UserID.ToString());
                    //更新用户信息
                    //UpdateYongHuXX(laihanxx.S_LAIHANBH);//20190325去掉用户信息更新
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.计划指标注销)
                {
                    //执行计划变更通过同步
                    helpTemp.P_YSLH_JIHUAZBZXTGTB(laihanxx.S_LAIHANBH, LoginInfo.CurrentUser.UserID.ToString());
                    //更新用户信息
                    //UpdateYongHuXX(laihanxx.S_LAIHANBH);//20190325去掉用户信息更新
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.并户)
                {
                    //获取源用户及结果用户
                    var drcTemp = new YS_LH_YONGHUTZProcess()
                        .SelectYS_LH_YONGHUTZsDynamic("S_LAIHANBH=" + laihanxx.S_LAIHANBH, null)
                        .Rows;
                    var yuanyonghuhList = new List<string>();
                    var resultyonghuh = "";
                    foreach (DataRow item in drcTemp)
                        if (item["I_YUANYONGH"].ToString() == "0")
                        {
                            yuanyonghuhList.Add("'"+item["S_YONGHUH"].ToString()+"'");
                        }
                        else
                        {
                            resultyonghuh = item["S_YONGHUH"].ToString();
                        }
                    //执行并户信息同步.
                    helpTemp.P_YS_LH_BINGHUSPTGTB(laihanxx.S_LAIHANBH, resultyonghuh, string.Join(",", yuanyonghuhList),
                        LoginInfo.CurrentUser.UserID.ToString());
                    //执行用户信息维护同步
                    helpTemp.P_YS_YONGHUXXWEIHUTB(resultyonghuh, null, 1, LoginInfo.CurrentUser.UserID.ToString(),
                        null);
                    //更新银行批量代理合同号
                    helpTemp.P_YS_YINHANGPLDLHTHXG(resultyonghuh, BusinessTool.GetHeTongH(laihanxx.S_YONGHUBH));
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.改户)
                {
                    int? error = 0;
                    //备份计划信息
                    helpTemp.P_YS_LH_BEIFENJHXX(laihanxx.S_LAIHANBH, laihanxx.S_YONGHUBH, out error);
                    helpTemp.P_YS_LH_GAIHUSHTG(laihanxx.S_LAIHANBH);
                    //获取改户号
                    var drcTemp = new YS_LH_YONGHUTZProcess()
                        .SelectYS_LH_YONGHUTZsDynamic("I_JLZT=0 AND S_LAIHANBH=" + laihanxx.S_LAIHANBH, null).Rows;
                    var yonghuh = "";
                    var hetongh = "";
                    foreach (DataRow item in drcTemp)
                    {
                        yonghuh = item["S_YONGHUH"].ToString();
                        hetongh = item["S_BEIYONG5"].ToString();
                        if (hetongh != "")
                        {
                            helpTemp.P_YS_YINHANGPLDLHTHXG(yonghuh, hetongh);
                        }
                    }
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.销户)
                {
                    //更新用户表用户状态为销户
                    new YS_YG_YONGHUXXBLL().UpdateYS_YG_YONGHUXXesDynamic(
                        string.Format(
                            "I_JLZT=-1,I_YONGHUZT=3,D_XIUGAIRQ=" + time + ",D_HUJIXGRQ=" + time + ",S_XIUGAIR={0}",
                            userid), "S_YONGHUH='" + laihanxx.S_YONGHUBH + "'");
                    //执行销户通过信息同步
                    helpTemp.P_YSLH_XIAOHUSPTGTB(laihanxx.S_LAIHANBH, laihanxx.S_YONGHUBH,
                        LoginInfo.CurrentUser.UserID.ToString());
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.销表)
                {
                    //获取要销的水表编号
                    var drc = new YS_LH_XIAOBIAOSBXXBLL()
                        .SelectYS_LH_XIAOBIAOSBXXesDynamic("S_LAIHANBH=" + laihanxx.S_LAIHANBH, null).Rows;
                    var shuibiaobhs = new List<string>();
                    foreach (DataRow item in drc)
                        shuibiaobhs.Add(item["S_SHUIBIAOBH"].ToString());
                    //执行销表通过信息同步
                    helpTemp.P_YS_LH_XIAOBIAOSPTGTB(laihanxx.S_LAIHANBH, laihanxx.S_YONGHUBH,
                        string.Join(",", shuibiaobhs), LoginInfo.CurrentUser.UserID.ToString());
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.分户)
                {
                    var errmsg = "";
                    int? errcode = 0;
                    helpTemp.P_YS_LH_FENHUSPTGTB(Convert.ToInt32(laihanxx.ID), out errmsg, out errcode);
                    //更新银行批量代理合同号 20190505 add
                    //获取分户号
                    var drcTemp = new YS_LH_YONGHUTZProcess()
                        .SelectYS_LH_YONGHUTZsDynamic("I_JLZT=0 AND S_LAIHANBH=" + laihanxx.S_LAIHANBH, null).Rows;
                    var yonghuh = "";
                    var hetongh = "";
                    foreach (DataRow item in drcTemp)
                    {
                        yonghuh = item["S_YONGHUH"].ToString();
                        hetongh = item["S_BEIYONG5"].ToString();
                        if (hetongh != "")
                        {
                            helpTemp.P_YS_YINHANGPLDLHTHXG(yonghuh, hetongh);
                        }
                    }
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.退款)
                {
                    // //通过后无需操作,剩余操作在退款确认中处理.
                    // todo by zzj 20181019: 去掉【退款确认】，处长审批同意后，直接退款
                    helpSQL.P_YSZW_TUIKUANQR_AUTO(laihanxx.S_LAIHANBH);
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源表过户)
                {
                    var rsno = "-1";
                    var rsmsg = "";
                    helpTemp.P_QSLH_BIAOGUOHSPTGTB(laihanxx.S_LAIHANBH, LoginInfo.CurrentUser.UserID.ToString(),
                        out rsno, out rsmsg);
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源并户)
                {
                    var rsno = "-1";
                    var rsmsg = "";
                    helpTemp.P_QS_LH_BINGHUSPTGTB(laihanxx.S_LAIHANBH, LoginInfo.CurrentUser.UserID.ToString(),
                        out rsno, out rsmsg);
                    //更新银行批量代理合同号 通常非托收暂不处理
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源采灌计划)
                {
                    var rsno = "-1";
                    var rsmsg = "";
                    helpTemp.P_QSLH_CAIGUANJHTZSPTGTB(laihanxx.S_LAIHANBH, LoginInfo.CurrentUser.UserID.ToString(),
                        out rsno, out rsmsg);
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源分户)
                {
                    var rsno = "-1";
                    var rsmsg = "";
                    helpTemp.P_QSLH_FENHUSPTGTB(laihanxx.S_LAIHANBH, LoginInfo.CurrentUser.UserID.ToString(), out rsno,
                        out rsmsg);
                    //更新银行批量代理合同号 通常非托收暂不处理
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源加价水量调整)
                {
                    var rsno = "-1";
                    var rsmsg = "";
                    helpTemp.P_QSLH_JIAJIASLTZSPTGTB(laihanxx.S_LAIHANBH, LoginInfo.CurrentUser.UserID.ToString(),
                        out rsno, out rsmsg);
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源井过户)
                {
                    var rsno = "-1";
                    var rsmsg = "";
                    helpTemp.P_QSLH_JINGUOHSPTGTB(laihanxx.S_LAIHANBH, LoginInfo.CurrentUser.UserID.ToString(),
                        out rsno, out rsmsg);
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源井性质修改)
                {
                    var rsno = "-1";
                    var rsmsg = "";
                    helpTemp.P_QSLH_JINZTXGSPTGTB(laihanxx.S_LAIHANBH, LoginInfo.CurrentUser.UserID.ToString(),
                        out rsno, out rsmsg);
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源深井类型修改)
                {
                    var rsno = "-1";
                    var rsmsg = "";
                    helpTemp.P_QSLH_JINLXXGSPTGTB(laihanxx.S_LAIHANBH, LoginInfo.CurrentUser.UserID.ToString(),
                        out rsno, out rsmsg);
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源注销井恢复)
                {
                    var rsno = "-1";
                    var rsmsg = "";
                    helpTemp.P_QSLH_XIAOJINHFSPTGTB(laihanxx.S_LAIHANBH, LoginInfo.CurrentUser.UserID.ToString(),
                        out rsno, out rsmsg);
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源开采计划)
                {
                    var rsno = "-1";
                    var rsmsg = "";
                    helpTemp.P_QSLH_KAICAIJHTZSPTGTB(laihanxx.S_LAIHANBH, LoginInfo.CurrentUser.UserID.ToString(),
                        out rsno, out rsmsg);
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源退款)
                {
                    //执行销户信息同步.
                    var rsno = "-1";
                    var rsmsg = "";
                    helpTemp.P_QSLH_TUIKUANSPTGTB(laihanxx.S_LAIHANBH, LoginInfo.CurrentUser.UserID.ToString(),
                        out rsno, out rsmsg);
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源销表)
                {
                    //执行销户信息同步.
                    var rsno = "-1";
                    var rsmsg = "";
                    helpTemp.P_QSLH_XIAOBIAOSPTGTB(laihanxx.S_LAIHANBH, LoginInfo.CurrentUser.UserID.ToString(),
                        out rsno, out rsmsg);
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源销户)
                {
                    var rsno = "-1";
                    var rsmsg = "";
                    helpTemp.P_QSLH_XIAOHUSPTGTB(laihanxx.S_LAIHANBH,laihanxx.S_YONGHUBH,LoginInfo.CurrentUser.UserID.ToString(), out rsno,
                        out rsmsg);
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源销井)
                {
                    var rsno = "-1";
                    var rsmsg = "";
                    helpTemp.P_QSLH_XIAOJINSPTGTB(laihanxx.S_LAIHANBH, LoginInfo.CurrentUser.UserID.ToString(),
                        out rsno, out rsmsg);
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源销取水口)
                {
                    var rsno = "-1";
                    var rsmsg = "";
                    helpTemp.P_QSLH_XIAOQSKSPTGTB(laihanxx.S_LAIHANBH, LoginInfo.CurrentUser.UserID.ToString(),
                        out rsno, out rsmsg);
                }
                else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源取水口过户)
                {
                    var rsno = "-1";
                    var rsmsg = "";
                    helpTemp.P_QSLH_QSKGUOHSPTGTB(laihanxx.S_LAIHANBH, LoginInfo.CurrentUser.UserID.ToString(),
                        out rsno, out rsmsg);
                }
            }
        }

        /// <summary>
        ///     来函通过后更新用户信息
        /// </summary>
        private static void UpdateYongHuXX(string laihanbh)
        {
            var oldyh = new YS_LH_YONGHUXXProcess().SelectYS_LH_YONGHUXXesDynamic(
                string.Format(" I_JLZT=0 and S_LAIHANBH='{0}'", laihanbh), "", null);
            if (oldyh != null && oldyh.Rows.Count > 0)
            {
                var dr = oldyh.Rows[0];
                var col =
                    "S_LIANXIDH='{0}',S_LIANXIR='{1}',S_YONGHUM='{2}',S_YOUBIAN='{3}',S_LIANXIBM='{4}',S_DIZHI='{5}' ";
                var where = "S_YONGHUH='{0}'";
                col = string.Format(col, dr["S_LIANXIDH"], dr["S_LIANXIR"], dr["S_YONGHUM"], dr["S_YOUBIAN"],
                    dr["S_LIANXIBM"], dr["S_DIZHI"]);
                where = string.Format(where, dr["S_YONGHUBH"]);
                new YS_YG_YONGHUXXBLL().UpdateYS_YG_YONGHUXXesDynamic(col, where);
            }
        }

        /// <summary>
        ///     加载来函流程右侧列表信息
        /// </summary>
        /// <param name="parent">控件</param>
        /// <param name="laihanxx">来函信息</param>
        public static void LoadRightInfo(Control parent, YS_LH_LAIHANXX laihanxx)
        {
            //条件区域
            var ucinfo = parent.FindControl("UCLHLCTOPINFO1") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //用户信息
            ucinfo = parent.FindControl("UCLHLCTOPINFO2") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //月度
            ucinfo = parent.FindControl("UCLHXX_YDTZ") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //计划指标注销
            ucinfo = parent.FindControl("UCLHShenQingXX_JHZBZX") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);

            //取水表信息
            ucinfo = parent.FindControl("UCLHBiaoInfoQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //取水井信息
            ucinfo = parent.FindControl("UCLHJinInfoQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //取水开采计划信息
            ucinfo = parent.FindControl("UCLHKaiCaiJHQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //取水采灌计划信息
            ucinfo = parent.FindControl("UCLHCaiGuanJHQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //取水加价调整信息
            ucinfo = parent.FindControl("UCLHJiaJiaSLInfoQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //取水加价调整列表信息
            ucinfo = parent.FindControl("UCLHJIAJIAXXListQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //取水退款信息
            ucinfo = parent.FindControl("UCLHTuiKuanInfoQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //取水分户信息
            ucinfo = parent.FindControl("UCLHFenHuQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //取水取水口相关水表信息
            ucinfo = parent.FindControl("UCLHShuiBiaoListQSK") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            ucinfo = parent.FindControl("UCLHFenHuTopInfo") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //加载申请信息
            ucinfo = parent.FindControl("UCLHShenQingXX") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //加载分户信息 20190426
            ucinfo = parent.FindControl("UCLHShenPiXX_FH") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //加载申请信息
            ucinfo = parent.FindControl("UCLHShenQingXX_JHBG") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //加载申请信息
            ucinfo = parent.FindControl("UCLHShenQingXX_BH") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //加载申请信息
            ucinfo = parent.FindControl("UCLHShenQingXX_BHQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //加载申请信息
            ucinfo = parent.FindControl("UCLHShuiBiaoList") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //加载申请信息
            ucinfo = parent.FindControl("UCLHShenQingXX_TK") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //加载申请信息
            ucinfo = parent.FindControl("UCLHShuiBiaoListQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);

            //加载分户水表信息
            ucinfo = parent.FindControl("UCLHFenHuShuiBiaoList") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);

            if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源深井类型修改 || laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源井性质修改 || laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源注销井恢复)
            {
                //ucinfo = parent.FindControl("UCLHJinInfo2QS") as IUCLHOperate;
                //ucinfo.LoadInfo(laihanxx);
                ucinfo = parent.FindControl("UCLHJinListQS") as IUCLHOperate;
                ucinfo.LoadInfo(laihanxx);
            }
            else if (laihanxx.I_LAIHANLX == (int)eLaiHanLX.水资源销户)
            {
                ucinfo = parent.FindControl("UCLHJinListQSView") as IUCLHOperate;
                ucinfo.LoadInfo(laihanxx);
                ucinfo = parent.FindControl("UCLHShuiBiaoListView") as IUCLHOperate;
                ucinfo.LoadInfo(laihanxx);
            }

            //改户
            ucinfo = parent.FindControl("UCLHGaiHuJHXX") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);

            //加载流程意见
            ucinfo = parent.FindControl("UCLHLCYIJIANS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //加载审批区域
            ucinfo = parent.FindControl("UCLHLCSHENPI") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //加载审批区域
            ucinfo = parent.FindControl("UCLHFenHuShenPiXX") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
            //加载按钮区域
            ucinfo = parent.FindControl("UCLHLCBTNS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.LoadInfo(laihanxx);
        }

        /// <summary>
        ///     清除来函流程右侧列表信息
        /// </summary>
        public static void ClearRightInfo(Control parent)
        {
            //清除右侧条件区域
            var ucinfo = parent.FindControl("UCLHLCTOPINFO1") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除右侧用户信息
            ucinfo = parent.FindControl("UCLHLCTOPINFO2") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除月度
            ucinfo = parent.FindControl("UCLHXX_YDTZ") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除计划指标注销
            ucinfo = parent.FindControl("UCLHShenQingXX_JHZBZX") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除表信息
            ucinfo = parent.FindControl("UCLHBiaoInfoQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除井信息
            ucinfo = parent.FindControl("UCLHJinInfoQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除开采计划信息
            ucinfo = parent.FindControl("UCLHKaiCaiJHQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除采灌计划信息
            ucinfo = parent.FindControl("UCLHCaiGuanJHQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除加价调整信息
            ucinfo = parent.FindControl("UCLHJIAJIAXXListQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除退款信息
            ucinfo = parent.FindControl("UCLHTuiKuanInfoQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除取水分户信息
            ucinfo = parent.FindControl("UCLHFenHuQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除取水口相关水表信息
            ucinfo = parent.FindControl("UCLHShuiBiaoListQSK") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除取水并户信息
            ucinfo = parent.FindControl("UCLHShenQingXX_BHQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            ///分户清空值
            ucinfo = parent.FindControl("UCLHFenHuTopInfo") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除申请信息
            ucinfo = parent.FindControl("UCLHShenQingXX") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除申请信息
            ucinfo = parent.FindControl("UCLHShenQingXX_BH") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除申请信息
            ucinfo = parent.FindControl("UCLHShenQingXX_JHBG") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除申请信息
            ucinfo = parent.FindControl("UCLHShenQingXX_TK") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除申请信息
            ucinfo = parent.FindControl("UCLHShuiBiaoList") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除申请信息
            ucinfo = parent.FindControl("UCLHShuiBiaoListQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除申请信息
            ucinfo = parent.FindControl("UCLHJinListQS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除申请信息
            ucinfo = parent.FindControl("UCLHJinInfo2QS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除分户申请信息
            ucinfo = parent.FindControl("UCLHFenHuShenPiXX") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //改户
            ucinfo = parent.FindControl("UCLHGaiHuJHXX") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除流程意见
            ucinfo = parent.FindControl("UCLHLCYIJIANS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除审批区域
            ucinfo = parent.FindControl("UCLHLCSHENPI") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
            //清除按钮区域
            ucinfo = parent.FindControl("UCLHLCBTNS") as IUCLHOperate;
            if (ucinfo != null)
                ucinfo.ClearInfo();
        }

        /// <summary>
        ///     来函登记提交验证(收件/收件齐全并登记)
        /// </summary>
        public static ValidateRS ValidateInfoDJ(Control parent)
        {
            var rs = new ValidateRS();
            //用户信息验证
            var ucinfo = parent.FindControl("UCLHUserInfo") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            //表信息验证
            ucinfo = parent.FindControl("UCLHBiaoInfoQS") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            //开采计划验证
            ucinfo = parent.FindControl("UCLHKaiCaiJHQS") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            //采灌计划验证
            ucinfo = parent.FindControl("UCLHCaiGuanJHQS") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            //加价调整信息验证
            ucinfo = parent.FindControl("UCLHJIAJIAXXListQS") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            //退款信息验证
            ucinfo = parent.FindControl("UCLHTuiKuanInfoQS") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            //取水分户信息验证
            ucinfo = parent.FindControl("UCLHFenHuQS") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            ///分户验证
            ucinfo = parent.FindControl("UCLHFenHuDJXX") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            //多分户验证 20190425 add
            ucinfo = parent.FindControl("UCLHShenQingXX_FH") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            //申请信息验证
            ucinfo = parent.FindControl("UCLHShenQingXX") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            //月度
            ucinfo = parent.FindControl("UCLHShenQingXX_YDTZ") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            //申请信息验证
            ucinfo = parent.FindControl("UCLHShenQingXX_JHBG") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            //申请信息验证
            ucinfo = parent.FindControl("UCLHShenQingXX_JHZBZX") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            //申请信息验证
            ucinfo = parent.FindControl("UCLHShenQingXX_BH") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            //申请信息验证
            ucinfo = parent.FindControl("UCLHShenQingXX_BHQS") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            //申请信息验证
            ucinfo = parent.FindControl("UCLHShenQingXX_TK") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            ucinfo = parent.FindControl("UCLHGaiHuTopInfo") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            //申请信息验证
            ucinfo = parent.FindControl("UCLHShuiBiaoList") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            //申请信息验证
            ucinfo = parent.FindControl("UCLHShuiBiaoListQS") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            //井类型,井状态,注销井恢复使用修改验证
            ucinfo = parent.FindControl("UCLHJinListQS") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            //申请信息验证
            ucinfo = parent.FindControl("UCLHShenQingLY") as IUCLHOperate;
            if (ucinfo != null)
            {
                rs = ucinfo.Validate();
                if (!rs.IsSuccess)
                    return rs;
            }
            rs.Msg = "成功";
            rs.IsSuccess = true;
            return rs;


        }

        /// <summary>
        ///     来函受理提交验证
        /// </summary>
        public static ValidateRS ValidateInfoSL(Control parent)
        {
            var rs = new ValidateRS();
            //申请理由验证
            var ucinfo = parent.FindControl("UCLHShenQingLY") as IUCLHOperate;
            rs = ucinfo.Validate();
            if (!rs.IsSuccess)
                return rs;
            rs.Msg = "成功";
            rs.IsSuccess = true;
            return rs;
        }

        /// <summary>
        ///     获取流程结果集中所需要的流程数据行所在的索引
        /// </summary>
        /// <param name="drc">结果集</param>
        /// <param name="lc">流程步骤</param>
        /// <returns></returns>
        public static List<int> GetNeedRowIndexs(DataRowCollection drc, int lx, eLaiHanLCBH lc)
        {
            var list = new List<int>();
            var id = -1;
            if (lx == (int)eLaiHanLX.年度 || lx == (int)eLaiHanLX.计划变更 || lx == (int)eLaiHanLX.并户 || lx == (int)eLaiHanLX.计划转移
                || lx == (int)eLaiHanLX.销户 || lx == (int)eLaiHanLX.销表 || lx == (int)eLaiHanLX.退款 ||
                lx == (int)eLaiHanLX.改户 || lx == (int)eLaiHanLX.表计因素注销 || lx == (int)eLaiHanLX.计划指标注销
                || lx >= 20)
            {
                var index = -1;
                for (var i = 0; i < drc.Count; i++)
                    if (Convert.ToInt32(drc[i]["ID"]) > id && Convert.ToInt32(drc[i]["I_LIUCHENGBH"]) == (int)lc)
                    {
                        index = i;
                        id = Convert.ToInt32(drc[i]["ID"]);
                    }
                if (index > -1)
                    list.Add(index);
            }
            else if (lx == (int)eLaiHanLX.基建调整)
            {
                var yBN = 2099;
                var indexBN = -1;
                var yXN = 1970;
                var indexXN = -1;
                for (var i = 0; i < drc.Count; i++)
                    if (Convert.ToInt32(drc[i]["I_LIUCHENGBH"]) == (int)lc)
                        if (Convert.ToInt32(drc[i]["I_Y"]) < yBN)
                        {
                            yBN = Convert.ToInt32(drc[i]["I_Y"]);
                            indexBN = i;
                            id = Convert.ToInt32(drc[i]["ID"]);
                        }
                        else if (Convert.ToInt32(drc[i]["I_Y"]) == yBN && Convert.ToInt32(drc[i]["ID"]) > id)
                        {
                            indexBN = i;
                            id = Convert.ToInt32(drc[i]["ID"]);
                        }
                id = -1;
                //获取下年所在记录
                for (var i = 0; i < drc.Count; i++)
                    if (Convert.ToInt32(drc[i]["I_LIUCHENGBH"]) == (int)lc)
                        if (Convert.ToInt32(drc[i]["I_Y"]) > yXN && Convert.ToInt32(drc[i]["ID"]) > id)
                        {
                            yXN = Convert.ToInt32(drc[i]["I_Y"]);
                            indexXN = i;
                            id = Convert.ToInt32(drc[i]["ID"]);
                        }
                        else if (Convert.ToInt32(drc[i]["I_Y"]) == yXN && Convert.ToInt32(drc[i]["ID"]) > id)
                        {
                            indexXN = i;
                            id = Convert.ToInt32(drc[i]["ID"]);
                        }
                if (indexBN > -1)
                    list.Add(indexBN);
                if (indexXN > -1)
                    list.Add(indexXN);
            }
            else if (lx == (int)eLaiHanLX.分户)
            {
                list.Add(0);
            }
            return list;
        }

        /// <summary>
        ///     获取当前流程的上一步流程
        /// </summary>
        /// <param name="lx">来函类型</param>
        /// <param name="lcNow">当前流程</param>
        /// <returns></returns>
        public static eLaiHanLCBH GetPreFlow(int lx, int lcNow)
        {
            //获取上一步骤
            var drT = new SpHelper().P_YS_LHGETNEXTFLOW(lx, lcNow, -1).Tables[0].Rows[0];
            return (eLaiHanLCBH)Enum.Parse(typeof(eLaiHanLCBH), drT["I_LIUCHENGBH"].ToString());
        }

        /// <summary>
        ///     是否存在流程中的关联来函
        /// </summary>
        /// <param name="lx">来函类型</param>
        /// <param name="yonghuh">用户号</param>
        /// <param name="y">年</param>
        /// <param name="m">月</param>
        /// <param name="msg">消息</param>
        /// <returns></returns>
        public static bool HasRelationExists(int laihanlx, string laihanbh, string yonghuh, string y, string m,
            out string msg)
        {
            //DataTable dt = null;
            string rsno, rsmsg;
            if (laihanlx == 1 || laihanlx == 6)//月调整、计划变更
                new SpHelper().P_YSLH_ValidPlanMonthOrChage(laihanbh, yonghuh, laihanlx, y, m, out rsno, out rsmsg);
            else
               new SpHelper().P_YSLH_PANDUANCZ(laihanbh, yonghuh, out rsno, out rsmsg);
            if (rsno == "-1")
            {
                msg = rsmsg;
                return true;
            }
            msg = "";
            return false;
        }
        /// <summary>
        /// 本月是否存在流程中的关联来函
        /// </summary>
        /// <param name="laihanlx">来函类型</param>
        /// <param name="yonghuh">用户号</param>
        /// <param name="y">年</param>
        /// <param name="m">月</param>
        /// <param name="msg">消息</param>
        /// <returns></returns>
        public static bool HasRelationExists(string laihanlx, string yonghuh, string y, string m,
            out string msg)
        {
            //DataTable dt = null;
            string rsno, rsmsg;
            new SpHelper().P_YSLH_PANDUANCZ(laihanlx, yonghuh, out rsno, out rsmsg);
            if (rsno == "-1")
            {
                msg = rsmsg;
                return true;
            }
            msg = "";
            return false;
        }
        /// <summary>
        ///     确认与提交验证
        /// </summary>
        /// <param name="parent">父级</param>
        /// <param name="opType">验证类型 queren:确认 tijiao:提交</param>
        /// <returns></returns>
        public static ValidateRS ValidateQueRenOrTiJiao(Control parent, string opType)
        {
            var rs = new ValidateRS();
            IUCLHOperate uc = null;
            if (opType == "queren")
            {
                var ucTemp = parent.FindControl("UCLHLCBTNS") as UCLHLCBTNS;
                if (ucTemp != null)
                    if (string.IsNullOrEmpty(ucTemp.LaiHanID))
                    {
                        rs.Msg = "未选择来函。";
                        return rs;
                    }
                var ucLaihan = parent.FindControl("UCLHLCLAIHANXX") as UCLHLCLAIHANXX;
                if (ucLaihan != null)
                {
                    rs = ucLaihan.ValidateQR();
                    if (!rs.IsSuccess)
                        return rs;
                }
                uc = parent.FindControl("UCLHLCSHENPI") as IUCLHOperate;
                if (uc != null)
                    rs = uc.Validate();
            }
            else if (opType == "tijiao")
            {
                uc = parent.FindControl("UCLHLCLAIHANXX") as IUCLHOperate;
                if (uc != null)
                    rs = uc.Validate();
            }
            else if (opType == "tijiao")
            {
                uc = parent.FindControl("UCLHLCLAIHANXX") as IUCLHOperate;
                if (uc != null)
                    rs = uc.Validate();
            }
            return rs;
        }


        /// <summary>
        ///     根据来函类型获取必需的文件
        /// </summary>
        public static string GetNeedFileBH(int laiHanLX)
        {
            var needFileBH = "0";
            switch ((eLaiHanLX)laiHanLX)
            {
                case eLaiHanLX.月度:
                    needFileBH = "2,11";
                    break;
                case eLaiHanLX.年度:
                    needFileBH = "1,11";
                    break;
                case eLaiHanLX.计划转移:
                    needFileBH = "4,11";
                    break;
                case eLaiHanLX.基建调整:
                    needFileBH = "3,11";
                    break;
                case eLaiHanLX.计划变更:
                    needFileBH = "5,11";
                    break;
                case eLaiHanLX.分户:
                    needFileBH = "11";
                    break;
                case eLaiHanLX.改户:
                    needFileBH = "11";
                    break;
                case eLaiHanLX.并户:
                    needFileBH = "11";
                    break;
                case eLaiHanLX.销户:
                    needFileBH = "11";
                    break;
                case eLaiHanLX.销表:
                    needFileBH = "11";
                    break;
                case eLaiHanLX.退款:
                    needFileBH = "11";
                    break;
                case eLaiHanLX.表计因素注销:
                    needFileBH = "11";
                    break;
                case eLaiHanLX.计划指标注销:
                    needFileBH = "11";
                    break;
                case eLaiHanLX.水资源表过户:
                    needFileBH = "14";
                    break;
                case eLaiHanLX.水资源并户:
                    needFileBH = "14";
                    break;
                case eLaiHanLX.水资源采灌计划:
                    needFileBH = "14";
                    break;
                case eLaiHanLX.水资源分户:
                    needFileBH = "14";
                    break;
                case eLaiHanLX.水资源加价水量调整:
                    needFileBH = "14";
                    break;
                case eLaiHanLX.水资源井过户:
                    needFileBH = "14";
                    break;
                case eLaiHanLX.水资源井性质修改:
                    needFileBH = "14";
                    break;
                case eLaiHanLX.水资源开采计划:
                    needFileBH = "14";
                    break;
                case eLaiHanLX.水资源深井类型修改:
                    needFileBH = "14";
                    break;
                case eLaiHanLX.水资源退款:
                    needFileBH = "14";
                    break;
                case eLaiHanLX.水资源销表:
                    needFileBH = "14";
                    break;
                case eLaiHanLX.水资源销户:
                    needFileBH = "14";
                    break;
                case eLaiHanLX.水资源销井:
                    needFileBH = "14";
                    break;
                case eLaiHanLX.水资源注销井恢复:
                    needFileBH = "14";
                    break;
                case eLaiHanLX.水资源销取水口:
                    needFileBH = "14";
                    break;
                case eLaiHanLX.水资源取水口过户:
                    needFileBH = "14";
                    break;
                default: needFileBH = "11"; break;
            }
            return needFileBH;
        }

        public static string GetUserFilesCondition(string yonghuh, string laihanbh, string needfileno)
        {
            string con = "I_JLZT=0 AND S_YONGHUBH='" + yonghuh + "' AND ";
            if (!string.IsNullOrEmpty(laihanbh))
            {
                //con = con + "(I_WENJIANLX=11 OR (S_LAIHANBH='" + laihanbh + "' AND I_WENJIANLX IN (" + needfileno + ")) OR (S_LAIHANBH IS NULL AND I_WENJIANLX NOT IN (" + needfileno + ")))";
                con = con + "(I_WENJIANLX=11 OR (S_LAIHANBH='" + laihanbh + "') OR (S_LAIHANBH IS NULL AND I_WENJIANLX NOT IN (" + needfileno + ")))";
            }
            else
            {
                con = con + "(I_WENJIANLX=11 OR (S_LAIHANBH IS NULL AND I_WENJIANLX IN(" + needfileno + ")) OR (S_LAIHANBH IS NULL AND I_WENJIANLX NOT IN (" + needfileno + ")))";
            }
            return con;
        }

        public static string GetYONGHUM_QS(string yhh)
        {
            string yhm = null;
            DataRowCollection drc = new QS_YG_YONGHUXXProcess().SelectQS_YG_YONGHUXXesDynamic("S_YONGHUH='" + yhh + "'", null).Rows;
            if (drc.Count == 0)
            {
                throw new Exception("未找到对应的用户,请检查数据");
            }
            else if (drc.Count > 1)
            {
                throw new Exception("同一用户数据超过1条,请检查");
            }
            else
            {
                yhm = Convert.ToString(drc[0]["S_YONGHUM"]);
            }
            return yhm;
        }

    }
}